package com.edu.exam.enums.curriculum.questionbank;

/**
 * 相关性枚举
 *
 * @author System
 * @version 1.0
 * @since 2025-11-15
 */
public enum Relevance {
    /**
     * 低相关性
     */
    LOW("LOW", "低相关性"),

    /**
     * 中等相关性
     */
    MEDIUM("MEDIUM", "中等相关性"),

    /**
     * 高相关性
     */
    HIGH("HIGH", "高相关性"),

    /**
     * 关键相关性
     */
    CRITICAL("CRITICAL", "关键相关性");

    private final String code;
    private final String description;

    Relevance(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据代码获取相关性
     *
     * @param code 代码
     * @return 相关性，找不到时返回默认值MEDIUM
     */
    public static Relevance fromCode(String code) {
        for (Relevance relevance : values()) {
            if (relevance.getCode().equals(code)) {
                return relevance;
            }
        }
        return MEDIUM;
    }
}